{% extends "base_generic.html" %}

{% block title %}All Borrowed Books{% endblock %}

{% block content %}
    <h1>All Borrowed Books</h1>

    {% if bookinstance_list %}
    <div class="table-responsive">
        <table class="table table-striped table-hover">
            <thead>
                <tr>
                    <th>Book</th>
                    <th>Author</th>
                    <th>Borrower</th>
                    <th>Due back</th>
                    <th>Status</th>
                    <th>Actions</th>
                </tr>
            </thead>
            <tbody>
                {% for bookinst in bookinstance_list %}
                <tr {% if bookinst.is_overdue %}class="danger"{% endif %}>
                    <td><a href="{{ bookinst.book.get_absolute_url }}">{{ bookinst.book.title }}</a></td>
                    <td>{{ bookinst.book.author }}</td>
                    <td>{{ bookinst.borrower }}</td>
                    <td>{{ bookinst.due_back }}</td>
                    <td>
                        {% if bookinst.is_overdue %}
                            <span class="label label-danger">Overdue</span>
                        {% else %}
                            <span class="label label-success">On loan</span>
                        {% endif %}
                    </td>
                    <td>
                        <a href="{% url 'renew-book-librarian' bookinst.pk %}" class="btn btn-sm btn-primary">
                            <span class="glyphicon glyphicon-refresh"></span> Renew
                        </a>
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
    {% else %}
        <div class="alert alert-info">
            <p>There are no books borrowed.</p>
        </div>
    {% endif %}

    {% block pagination %}
        {{ block.super }}
    {% endblock %}
{% endblock %} 